<?php
// 本类由系统自动生成，仅供测试用途

//import("ORG.Util.Page");

class BulletinAction extends Action{

	public function bulletin(){

		//公告
		$Bulletin = new Model('Bulletin');
    	$bulletin_id = (int)$_GET['bulletin_id'];
		$bulletin = $Bulletin->where('bulletin_id='.$bulletin_id)->find();

		//公告附件
		$Affix = new Model('Bulletinaffix');
		$affixes = $Affix->where('bulletin_id='.$bulletin_id)->findAll();

		$this->assign('affixes',$affixes);
		$this->assign('bulletin',$bulletin);
		$this->display();
    }

    //公告类列表，主类型
    public function  bulletinList(){
    	import("ORG.Util.Page");
    	$Bulletin = new Model('Bulletin');

    	$type = $_GET['type'];

    	switch ($type){
    		case 0:
    			$bulletinType = '教工事务';
    			break;
    		case 1:
    			$bulletinType = '研究生事务';
    			break;
    		case 2:
    			$bulletinType = '本科生事务';
    			break;
    		default:
    			$bulletinType = '科研通知';

    	}

    	$count = $Bulletin->where('type='.$type)->count();
    	$Page = new Page($count, 15);
    	$show = $Page->show();

    	$list = $Bulletin->where('type='.$type)->order('bulletin_id desc')->limit($Page->firstRow.','.$Page->listRows)->select();

    	$this->assign('bulletinType',$bulletinType);
    	$this->assign('bulletinList',$list);
    	$this->assign('page',$show);
    	$this->display();

    }

    //公告类列表，本科生事务的子类型
	public function  subBulletinList(){
    	import("ORG.Util.Page");
    	$Bulletin = new Model('Bulletin');

    	$subtype = $_GET['subtype'];

    	switch ($subtype){
    		case 0:
    			$bulletinType = '课程表';
    			break;
    		case 1:
    			$bulletinType = '教务通知';
    			break;
    		default:
    			$bulletinType = '学籍管理';
    			break;
    	}

    	$count = $Bulletin->where('type=2 AND subtype='.$subtype)->count();
    	$Page = new Page($count, 15);
    	$show = $Page->show();

    	$list = $Bulletin->where('type=2 AND subtype='.$subtype)->order('bulletin_id desc')->limit($Page->firstRow.','.$Page->listRows)->select();

    	$this->assign('bulletinType',$bulletinType);
    	$this->assign('bulletinList',$list);
    	$this->assign('page',$show);
    	$this->display('bulletinList');

    }

}
?>
